//
//  FoodListTableViewCell.m
//  Recipe
//
//  Created by YaSha_Tom on 2018/12/17.
//  Copyright © 2018年 YaSha-Tom. All rights reserved.
//

#import "FoodListTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface FoodListTableViewCell ()
@property(nonatomic,strong)UIImageView *foodImage;
@property(nonatomic,strong)UILabel *foodNameLabel;
@property(nonatomic,strong)UILabel *foodInfoLabel;
@end

@implementation FoodListTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}
- (void)initUI {
    self.foodImage = [[UIImageView alloc]init];
    [self addSubview:self.foodImage];
    [self.foodImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(5);
        make.left.mas_equalTo(self.mas_left).offset(15);
        make.size.mas_equalTo(CGSizeMake(100*kWidthScale, 100*kHeightScale));
    }];
    
    self.foodNameLabel = [[UILabel alloc]init];
    self.foodNameLabel.font = [UIFont fontWithName:@"Helvetica-Bold"  size:18];
    [self addSubview:self.foodNameLabel];
    [self.foodNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).offset(10);
        make.left.mas_equalTo(self.foodImage.mas_right).offset(15);
        make.size.mas_equalTo(CGSizeMake(200*kWidthScale, 20*kHeightScale));
    }];
    
    self.foodInfoLabel  =[[UILabel alloc]init];
    self.foodInfoLabel.font = [UIFont boldSystemFontOfSize:14];
    self.foodInfoLabel.numberOfLines = 0;
    [self addSubview:self.foodInfoLabel];
    [self.foodInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.foodNameLabel.mas_bottom).offset(5);
        make.left.mas_equalTo(self.foodImage.mas_right).offset(15);
        make.size.mas_equalTo(CGSizeMake(240*kWidthScale, 70*kHeightScale));
    }];
}
- (void)setFoodListData:(FoodListModel *)cellModel {
    NSLog(@"=====%@",cellModel.albums[0]);
    [self.foodImage sd_setImageWithURL:[NSURL URLWithString:cellModel.albums[0]] placeholderImage:[UIImage imageNamed:@""]];
    self.foodNameLabel.text = cellModel.title;
    self.foodInfoLabel.text = cellModel.imtro;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
